﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace template_dll
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public string text = "";

        private void Form2_Load(object sender, EventArgs e)
        {
            textBox1.Text = text;
            label1.Text = "Осталось символов: " + (256 - text.Length).ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            text = textBox1.Text;
            this.DialogResult = DialogResult.OK;
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (textBox1.Text.Length > 255)
            {
                if (e.KeyChar != (char)Keys.Back)
                {
                    e.Handled = true;
                }
            }
            if (e.KeyChar == (char)Keys.Enter)
            {
                EventArgs ea = new EventArgs();
                button1_Click(sender, ea);
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            label1.Text = "Осталось символов: " + (255 - textBox1.Text.Length).ToString();
        }
    }
}
